package InterfaceLambdaAndInnerClasses.anonymousInnerClass;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.util.Date;

class TalkingClock {
    void start(int interval, boolean beep) {
        ActionListener listener = e -> {
            System.out.println("At the tone,the time is " + new Date());
            if(beep) Toolkit.getDefaultToolkit().beep();
        };
        Timer timer=new Timer(interval,listener);
        timer.start();
    }
}
